import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDSkillGlobal {
	/**Key*/
	id,
	/**参数值*/
	Value,

	/**枚举数量*/
	EnumCount
}



export class CDSkillGlobal{
	/**Key*/
	public id: number;
	/**参数值*/
	public Value: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDSkillGlobal.id: return this.id;
			case E_CDSkillGlobal.Value: return this.Value;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDSkillGlobal.id: this.id = v; break;
			case E_CDSkillGlobal.Value: this.Value = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDSkillGlobal> = new HashMap<number, CDSkillGlobal>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDSkillGlobal[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDSkillGlobal();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].Value = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDSkillGlobal{
		return this.datas ? this.datas.get(id) : null;
	}
}
